package com.bawei.park2211a.news


import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.bawei.base.bean.NewsEntity
import com.bawei.base.mvvm.BaseViewModel
import com.bawei.base.net.ApiService

import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow

import javax.inject.Inject

@HiltViewModel
class NewsViewModel @Inject constructor(var apiService: ApiService):BaseViewModel(){
    fun getNewsByType(): Flow<PagingData<NewsEntity>> {
        return Pager(PagingConfig(10), pagingSourceFactory = {
            NewsDataSource(apiService)
        }).flow
    }
}